<!--班车每日点名信息页-->
<template>
    <div style="height: 100%;">
        <m-page-list
                :option="option"
                :page="page"
                :total="total"
                :table-data="tableData"
                :table-loading="tableLoading"
                v-model:value="query"
                @h-btn-click="hBtnClick"
                @col-btn-click="colBtnClick"
                @search-data="searchData"
        />
        <m-dialog-form ref="dialogRef" :data="dialogData" v-model:show="dialogShow" :option="dialogOption" @confirm="dialogConfirm" ></m-dialog-form>

        <el-dialog class="dialog-wrap" v-model="detailShow" width="95%" :title="detailTitle" :close-on-click-modal="false" draggable align-center destroy-on-close>
            <shuttle-detail style="height: 90vh;" class="dtl-wrap" :data="shuttleData" @save="getDataList"></shuttle-detail>
        </el-dialog>

    </div>
</template>

<script setup>

  import {useRouter} from 'vue-router'
  import {ref,reactive,onMounted,nextTick} from 'vue'
  //组件
  import MPageList from '@/components/PageList'
  import MDialogForm from '@/components/DialogForm/DialogForm'
  import ShuttleDetail from './RollcallDailyShuttleDetail'
  //请求
  import {getRollCallDailyShuttleData, addRollCallDailyShuttleData,editRollCallDailyShuttleData,delRollCallDailyShuttleData,
    getRole,getEmployeeInf} from '@/request/api/basicData'

  import {usePageList} from "../../composables/pageList";
  import {refOpt} from "../const";
  import {crtTimeFtt} from "../../utils/utils";

  const router = useRouter();

  let opts = {
    auth_id: 'e_rollcall_shuttle',
    getApi: getRollCallDailyShuttleData,addApi:addRollCallDailyShuttleData,editApi:editRollCallDailyShuttleData,delApi:delRollCallDailyShuttleData,
    idKey: 'row_id',
  };
  let {option,page,total,tableLoading,tableData,query,dialogRef,dialogShow,dialogData,dialogOption,
    hBtnClick,colBtnClick,searchData,getDataList,dialogConfirm} = usePageList(opts);

  /* 顶部标题导航 */
  /*option.titleList = [
    {name: '班车基础点名信息',path: '/rollcallDailyShuttle'},
    {name: '班车基础点名座位信息',path: '/rollcallDailyShuttleSeat'},
  ]*/
  /*查询条件*/
  option.conditions = [
    {label: '日期',field_id: 'shuttle_date', type: 'date',length: 'YYYY-MM-DD',col: 6},
    {...refOpt.rollcall_shuttle_name,label: '点名班车',field_id: 'shuttle_name',col: 6,rewriteInput: true,
      refCols: [
        {prop: 'row_id',label: '行号' },
        {prop: 'shuttle_no',label: '点名班车号' },
        {prop: 'shuttle_name',label: '点名班车名' },
        {prop: 'direction',label: '方向' },
      ]},
    {label: '班车类型',field_id: 'shuttle_type',type: 'picklist',options: [{name: '车站客运班车',id: '车站客运班车'},{name: '定制',id: '定制'},],col: 6},
    {...refOpt.shuttle_direction_name,field_id: 'direction',label: '方向',col:6, valueKey: [{'direction': 'shuttle_direction_name'}] ,rewriteInput: true},
  ];
  const today = crtTimeFtt(new Date(),'YYYY-MM-DD');
  query.value = {shuttle_date: today}   //默认当天查询条件
  /*表格列*/
  option.cols = [
    {prop: 'shuttle_date', label: '日期',},
    {prop: 'shuttle_no', label: '点名班车号',},
    {prop: 'shuttle_name', label: '点名班车名',},
    {prop: 'shuttle_type', label: '班车类型',},
    {prop: 'basic_shuttle_id', label: '关联基础班次id',},
    {prop: 'direction',label: '方向' },
    {prop: 'state',label: '检票状态'},
    {prop: 'all_get_off_pic',label: '全部人已下车照片',type: 'picture' },
    {prop: 'shuttle_seat_id',label: '售票班车座位表号' },
    {prop: 'shuttle_seat_name',label: '售票班车座位表名' },
    {prop: 'is_used',label: '启用标识', type: 'bool'},
    {prop: 'line_name',label: '线路名'},
    {prop: 'first_stop_name',label: '起点'},
    {prop: 'last_stop_name',label: '终点'},
    {prop: 'seat_count',label: '客座数'},
    {prop: 'vehicle_no',label: '车牌号码'},
    {prop: 'driver_no',label: '司机工号'},
    {prop: 'driver_name',label: '司机姓名'},
    {prop: 'caretaker_no',label: '照管员号'},
    {prop: 'caretaker_name',label: '照管员名'},
    {prop: 'caretaker_no_2',label: '照管员号2'},
    {prop: 'caretaker_name_2',label: '照管员名2'},
    {prop: 'caretaker_no_3',label: '照管员号3'},
    {prop: 'caretaker_name_3',label: '照管员名3'},
    {prop: 'rollcall_admin_no',label: '点名管理人号'},
    {prop: 'rollcall_admin_name',label: '点名管理人名'},
    {prop: 'rollcall_admin_no_2',label: '点名管理人号2'},
    {prop: 'rollcall_admin_name_2',label: '点名管理人名2'},
    {prop: 'rollcall_admin_no_3',label: '点名管理人号3'},
    {prop: 'rollcall_admin_name_3',label: '点名管理人名3'},
    {prop: 'batch_no',label: '批次号'},
    {prop: 'line_name',label: '线路名'},
    {prop: 'first_departure_time',label: '始发时间'},
    {prop: 'first_stop_name',label: '起点'},
    {prop: 'last_stop_name',label: '终点'},
    {prop: 'first_rollcall_no',label: '首次点名员号' },
    {prop: 'first_rollcall_name',label: '首次点名员名' },
    {prop: 'input_name',label: '首次点名时间' },
    {prop: 'last_rollcall_no',label: '最后点名员号' },
    {prop: 'last_rollcall_name',label: '最后点名员名' },
    {prop: 'last_rollcall_time',label: '最后点名时间' },

  ];

  option.colBtns.shift();
  option.colBtns.unshift(
    {title: '查看',id: 'detail',type: 'primary',event: checkDetail},
  );

  /*新增编辑弹窗字段*/
  dialogOption.fieldList = [
    {field_id: 'shuttle_date',label: '日期',type: 'date',dateFormat: 'YYYY-MM-DD',col: 2 },
    {field_id: 'is_used',label: '启用标识', type: 'bool',col:2,},
    {...refOpt.rollcall_shuttle_id,field_id: 'shuttle_no',col:2, label: '点名班车号',required: true},
    {...refOpt.rollcall_shuttle_name,editDisabled: true,col:2, label: '点名班车名',required: true,
      valueKey: ['shuttle_no','shuttle_name','direction','shuttle_seat_id','shuttle_seat_name','seat_count','vehicle_no','driver_no','driver_name','caretaker_no','caretaker_name','rollcall_admin_no','rollcall_admin_name'],
      refCols: [
        {prop: 'row_id',label: '行号' },
        {prop: 'shuttle_no',label: '点名班车号' },
        {prop: 'shuttle_name',label: '点名班车名' },
        {prop: 'direction',label: '方向' },
      ]},
    {...refOpt.shuttle_seat_id,col:2, label: '售票班车座位表号'},
    {...refOpt.shuttle_seat_name,col:2, label: '售票班车座位表名'},

    {field_id: 'shuttle_type',label: '班车类型',type: 'picklist',options: [{label:'车站客运班车',value:'车站客运班车'},{label:'定制',value:'定制'}],defaultValue:'车站客运班车',col: 2 },
    {...refOpt.shuttle_direction_name,field_id: 'direction',label: '方向',col:2, valueKey: [{'direction': 'shuttle_direction_name'}] ,},
    {field_id: 'first_departure_time',label: '始发时间',type: 'time',col:2,},
    {field_id: 'line_name',label: '线路名',type: 'text',col:2},
    {field_id: 'first_stop_name',label: '起点',type: 'text',col:2},
    {field_id: 'last_stop_name',label: '终点',type: 'text',col:2},
    {field_id: 'seat_count',label: '客座数',type: 'number',col:2,},
    {field_id: 'vehicle_no',label: '车牌号码',type: 'text',col:2,},
    {...refOpt.driver_no,col:2,},
    {...refOpt.driver_name,col:2,},
    {...refOpt.caretaker_no,col:2,},
    {...refOpt.caretaker_name,col:2,},
    {...refOpt.caretaker_no, label: '照管员号2',field_id: 'caretaker_no_2',col:2},
    {...refOpt.caretaker_name, label: '照管员名2',field_id: 'caretaker_name_2',col:2, valueKey: [{'caretaker_no_2': 'caretaker_no'},{'caretaker_name_2': 'caretaker_name'}]},
    {...refOpt.caretaker_no, label: '照管员号3',field_id: 'caretaker_no_3',col:2},
    {...refOpt.caretaker_name, label: '照管员名3',field_id: 'caretaker_name_3',col:2, valueKey: [{'caretaker_no_3': 'caretaker_no'},{'caretaker_name_3': 'caretaker_name'}]},
    {...refOpt.rollcall_admin_no,col:2,},
    {...refOpt.rollcall_admin_name,col:2,},
    {...refOpt.rollcall_admin_no, label: '点名管理人号2',field_id: 'rollcall_admin_no_2',col:2,},
    {...refOpt.rollcall_admin_name, label: '点名管理人名2',field_id: 'rollcall_admin_name_2',col:2, valueKey: [{'rollcall_admin_no_2': 'rollcall_admin_no'},{'rollcall_admin_name_2': 'rollcall_admin_name'}],},
    {...refOpt.rollcall_admin_no, label: '点名管理人号3',field_id: 'rollcall_admin_no_3',col:2,},
    {...refOpt.rollcall_admin_name, label: '点名管理人名3',field_id: 'rollcall_admin_name_3',col:2, valueKey: [{'rollcall_admin_no_3': 'rollcall_admin_no'},{'rollcall_admin_name_3': 'rollcall_admin_name'}],},
    {field_id: 'remarks',label: '备注',type: 'text',col:4,},
  ];
  function checkSeat(scope) {
    router.push({
      path:'/rollcallDailyShuttleSeat',query: {shuttle_id: scope.row.shuttle_no}
    })
  }

  /*----------------  ----------------*/
  let detailShow = ref(false),
    shuttleData = ref({}),
    detailTitle = ref('查看');
  function checkDetail(scope,id) {
    detailShow.value = true;
    shuttleData.value = scope.row;
    detailTitle.value = scope.row.shuttle_name;
  }


</script>

<style scoped>

</style>
